package com.hbnu.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hbnu.system.core.base.CommonPage;
import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.dto.CheckBackDTO;
import com.hbnu.system.model.dto.SearchPageDTO;
import com.hbnu.system.model.dto.UserDTO;
import com.hbnu.system.model.entity.Meeting_host;
import com.hbnu.system.service.IMeeting_hostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/meeting_host")
@Api(tags = "主办会议模块")
public class Meeting_hostController {
    @Autowired
    IMeeting_hostService iMeeting_hostService;

    @ApiOperation("主办会议录入")
    @PostMapping("/addHostMeeting")
    public Rest<Boolean> AddHostmeeting(@RequestBody Meeting_host meeting_host){
        boolean add = iMeeting_hostService.addmeethost(meeting_host);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("主办会议删除")
    @GetMapping("/DeleteHostMeeting")
    public Rest<Boolean> DeleteHostMeeting(String ID){
        boolean delete = iMeeting_hostService.deletemeethost(ID);
        return delete ? Rest.success() : Rest.failed();
    }

    @ApiOperation("主办会议修改")
    @PostMapping("/UpdateHostMeeting")
    public Rest<Boolean> UpdateHostMeeting(@RequestBody Meeting_host meeting_host){
        boolean update = iMeeting_hostService.updatemeethost(meeting_host);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("主办会议提交")
    @GetMapping("/ReCommitHostMeeting")
    public Rest<Boolean> ReCommitHostMeeting(String ID){
        boolean add = iMeeting_hostService.ReCommitMeetinghost(ID);
        return add ? Rest.success() : Rest.failed();
    }
    @ApiOperation("主办会议名称查重")
    @GetMapping("/CheckHostMeetingName")
    public Rest<Boolean> CheckHostMeetingName(String name){
        boolean check = iMeeting_hostService.checkmeethostName(name);
        return check ? Rest.success() : Rest.failed();
    }

    @ApiOperation("根据主键主办会议查询")
    @GetMapping("/GetHostMeetingById")
    public Rest<Meeting_host> GetHostMeetingById(String ID){
        Meeting_host mt = iMeeting_hostService.getmeethostbyid(ID);
        return Rest.success(mt);
    }
    @ApiOperation("主办会议分页查询")
    @PostMapping ("/pagecondition")
    public Rest<CommonPage<Meeting_host>> pageProjectCondition(@RequestBody SearchPageDTO searchTaskDTO){
        IPage<Meeting_host> page = iMeeting_hostService.pageCondition(searchTaskDTO);
        CommonPage<Meeting_host> activityVOCommonPage = CommonPage.restPage(page);
        return Rest.success(activityVOCommonPage);
    }
    @ApiOperation("主办会议校级通过")
    @GetMapping("/SchoolCheckPass")
    public Rest<String> SchoolPassmeetinghost(@RequestHeader("X-Token") String token,String PID){
        Boolean b = iMeeting_hostService.schoolCheckPass(token,PID);
        return b ? Rest.success() : Rest.failed();
    }

    @ApiOperation("主办会议校级退回回")
    @PostMapping("/SchoolCheckBack")
    public Rest<String> SchoolBackmeetinghost(@RequestHeader("X-Token") String token,@RequestBody CheckBackDTO checkBackDTO){
        Boolean b = iMeeting_hostService.schoolCheckBack(token,checkBackDTO);
        return b ? Rest.success() : Rest.failed();
    }
    @ApiOperation("用户获取与自己相关的主办会议分页")
    @PostMapping("/UserGetRelateHostMeeting")
    public Rest<CommonPage<Meeting_host>> UserGetRelatehostmeeting(@RequestBody UserDTO userDTO){
        IPage<Meeting_host> mtIPage = iMeeting_hostService.userGetRelateHostmeeting(userDTO);
        CommonPage<Meeting_host> mtCommonPage = CommonPage.restPage(mtIPage);
        return Rest.success(mtCommonPage);
    }

//    @ApiOperation("院级管理员查看需要自己审核的论文-分页")
//    @PostMapping("/CollegeUserGetPaper")
//    public Rest<CommonPage<Paper>> CollegeUserGetPaper(@RequestBody UserDTO userDTO){
//        IPage<Paper> paperIPage = iPaperService.collegeUserGetPaper(userDTO);
//        CommonPage<Paper> paperCommonPage = CommonPage.restPage(paperIPage);
//        return Rest.success(paperCommonPage);
//    }

    @ApiOperation("校级管理员查看需要自己审核的主办会议分页")
    @PostMapping("/SchoolUserGetHostMeeting")
    public Rest<CommonPage<Meeting_host>> SchoolUserGethostmeeting(@RequestBody UserDTO userDTO){
        IPage<Meeting_host> mtIPage = iMeeting_hostService.schoolUserGetHostmeeting(userDTO);
        CommonPage<Meeting_host> mtCommonPage = CommonPage.restPage(mtIPage);
        return Rest.success(mtCommonPage);
    }
}

